//
//  CZVideoPlayViewController.m
//  nsj_iOS
//
//  Created by apple on 2017/3/3.
//  Copyright © 2017年 GCZ. All rights reserved.
//

#import "CZVideoPlayViewController.h"
#import "ZFPlayer.h"

@interface CZVideoPlayViewController () <ZFPlayerDelegate>
@property (nonatomic, strong) ZFPlayerView *playerView;

@end

@implementation CZVideoPlayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.playerView = [[ZFPlayerView alloc] init];
    [self.view addSubview:self.playerView];
    [self.playerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(20);
        make.left.right.equalTo(self.view);
        // 这里宽高比16：9，可以自定义视频宽高比
        make.height.equalTo(self.playerView.mas_width).multipliedBy(9.0f/16.0f);
    }];
    
    // 初始化控制层view(可自定义)
    ZFPlayerControlView *controlView = [[ZFPlayerControlView alloc] init];
    // 初始化播放模型
    //    controlView
    ZFPlayerModel *playerModel = [[ZFPlayerModel alloc]init];
    playerModel.videoURL = [NSURL URLWithString:self.videoURL];
//    playerModel.title = @"hah ";
    playerModel.fatherView = self.view;
    [self.playerView playerControlView:controlView playerModel:playerModel];
    
    // 设置代理
    self.playerView.delegate = self;
    // 自动播放
    [self.playerView autoPlayTheVideo];
    
    // Do any additional setup after loading the view.
}
- (void)zf_playerBackAction {
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
